﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace stringTest
{
    class Program
    {

        static string Copy(string str)
        {
            char[] arr = str.ToCharArray();
            return new string(arr);
        }

        public static object Clone(object obj)
        {
            MemoryStream memoryStream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(memoryStream, obj);
            memoryStream.Position = 0;
            return formatter.Deserialize(memoryStream);
        }

        static void Main(string[] args)
        {
            /*
             字符串深度复制
             */
            /*List<string> lists = new List<string>();

            lists.Add("hello");
            lists.Add("word");

            string str = Clone( lists[0]) as string;
            Console.WriteLine("str:" + str);

            foreach(var s in lists)
            {
                Console.WriteLine(s);
            }

            lists.Clear();

            Console.WriteLine("str:" + str);*/

            byte[] bytes = { 0xa0, 0x2a, 0x00, 0x20, 0xe9, 0x65, 0x00, 0x08, 0x19, 0x8a };
            string str = Encoding.Unicode.GetString(bytes);
            byte[] bytes2 = Encoding.Unicode.GetBytes(str);
            foreach (var b in bytes2) {
                Console.WriteLine(b.ToString("X2"));
            }




            //            string resultStr = @"Microsoft Windows [版本 6.1.7601]
            //版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

            //D:\NiRen\NRBackground>cd D:\NiRen\NRBackground\db\db5.5\bin

            //D:\NiRen\NRBackground\db\db5.5\bin>mysql -u root -pjaunt -Dmysql < D:\NiRen\NRBackground\db\niren.sql
            //t_error
            //0
            //t_error
            //0

            //D:\NiRen\NRBackground\db\db5.5\bin>exit";

            //            if (resultStr.Contains("t_error") == true)
            //                Console.WriteLine("创建完成");
            //            else
            //                Console.WriteLine("创建失败");



            //Dictionary<string, string> dicStr = new Dictionary<string, string>();

            //DateTime dt = DateTime.Now;

            //string str = dt.ToString("yyyy-MM-01");

            //Console.WriteLine("日期："+str);

            //string test = "1,254,56,22";
            //string str = test.Substring(0, test.IndexOf(','));

            //Console.WriteLine(str);
            //test = test.Substring(test.IndexOf(',') + 1, test.Length - (test.IndexOf(',') + 1));

            //str = test.Substring(0, test.IndexOf(','));
            //Console.WriteLine(str);

            //test = test.Substring(test.IndexOf(',') + 1, test.Length - (test.IndexOf(',') + 1));

            //str = test.Substring(0, test.IndexOf(','));
            //Console.WriteLine(str);

            //test = test.Substring(test.IndexOf(',') + 1, test.Length - (test.IndexOf(',') + 1));

            //str = test;
            //Console.WriteLine(str);

            //DateTime dt = CalcSystemTime(10);// 416314894);
            //dt.AddDays(3);
            //Console.WriteLine(dt);

            //dicStr.Add("1", "珠海");
            //dicStr.Add("2", "中山");
            //dicStr.Add("3", "广州");
            //dicStr.Add("4", "深圳");
            //dicStr.Add("5", "湛江");

            ////Lambda表达式 的排序方法
            //var list = dicStr.OrderBy(s => s.Value);

            //foreach (var s in dicStr)
            //{
            //    Console.WriteLine(s.Key + " " + s.Value);
            //}

            //Console.WriteLine("*******************************************");

            //foreach (var s in list)
            //{
            //    Console.WriteLine(s.Key + " " + s.Value);
            //}



            Console.ReadLine();
        }

        public static DateTime CalcSystemTime(uint TotalSeconds)
        {
            DateTime oldDt = Convert.ToDateTime("2006-01-01 00:00:00");

            oldDt.AddSeconds(TotalSeconds);//将秒数加起来

            return oldDt;
        }


    }
}
